@ECHO OFF & CD /D %~DP0 & TITLE 绿化
>NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
    ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
    ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
    "%TEMP%\Getadmin.vbs"
    DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL
    Exit /b
)

taskkill /f /im PDFelement*  >NUL 2>NUL

if "%PROCESSOR_ARCHITECTURE%"=="x86"  reg add "HKLM\Software\PEPrinter\Wondershare PDFelement Monitor" /f /v InstallName /d "%~dp0PDFelement.exe" >NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64"  reg add "HKLM\Software\Wow6432Node\PEPrinter\Wondershare PDFelement Monitor" /f /v InstallName /d "%~dp0PDFelement.exe" >NUL

if "%PROCESSOR_ARCHITECTURE%"=="x86"  reg add "HKLM\Software\Wondershare\Wondershare PDFelement 6 Pro" /f /v InstallPath /d "%~dp0\" >NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64"  reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 6 Pro" /f /v InstallPath /d "%~dp0\" >NUL

if "%PROCESSOR_ARCHITECTURE%"=="x86"  reg add "HKLM\Software\Wondershare\Wondershare PDFelement 6 Pro" /f /v appsetuppath /d "%~dp0\" >NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64"  reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 6 Pro" /f /v appsetuppath /d "%~dp0\" >NUL

::这是官方OCR组件安装包检测的必要键值，制作绿色版所需要的；
if "%PROCESSOR_ARCHITECTURE%"=="x86"  reg add "HKLM\Software\Wondershare\Wondershare PDFelement 6 Pro" /f /v RegAppVersion /d "6.5.0.3226" >NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64"  reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare PDFelement 6 Pro" /f /v RegAppVersion /d "6.5.0.3226" >NUL

::这是客户标识,必须要有个ID存在，没有则在某些系统上启动不了。
if "%PROCESSOR_ARCHITECTURE%"=="x86"  reg add "HKLM\Software\Wondershare\Wondershare Helper Compact" /f /v ClientSign /d "{12F37D32-C0FA-4D3F-9A22-BFF4835E4B5C}" >NUL
if "%PROCESSOR_ARCHITECTURE%"=="AMD64"  reg add "HKLM\Software\Wow6432Node\Wondershare\Wondershare Helper Compact" /f /v ClientSign /d "{12F37D32-C0FA-4D3F-9A22-BFF4835E4B5C}" >NUL

::start /wait /B "" "%~dp0Wondershare Helper Compact.exe" /VERYSILENT
start /wait /B "" "%~dp0FileAssociation.exe"  /InstallFileAssociate

::ping -n 5 127.0.0.1 >NUL 2>NUL

reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "Wondershare Helper Compact.exe" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run" /f /v "Wondershare Helper Compact.exe" >NUL 2>NUL

ECHO.&ECHO 绿化完成！创建快捷方式？
ECHO.&ECHO 是按任意键，否直接关闭！&PAUSE >NUL 2>NUL

mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\万兴PDF编辑器.lnk""):b.TargetPath=""%~dp0PDFelement.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")

CLS &ECHO.&ECHO 创建完成！&PAUSE >NUL 2>NUL & EXIT